package com.drop.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Order entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order", catalog = "feature_mall")
public class Order implements java.io.Serializable {

	// Fields

	private Integer orderId;
	private Shipaddress shipaddress;
	private State state;
	private User user;
	private Float sumMoney;
	private String orderTime;
	private String address;
	private Set<Childorder> childorders = new HashSet<Childorder>(0);
	private Set<Comment> comments = new HashSet<Comment>(0);

	// Constructors

	/** default constructor */
	public Order() {
	}

	/** full constructor */
	public Order(Shipaddress shipaddress, State state, User user,
			Float sumMoney, String orderTime, String address,Set<Childorder> childorders,
			Set<Comment> comments) {
		this.shipaddress = shipaddress;
		this.state = state;
		this.user = user;
		this.sumMoney = sumMoney;
		this.orderTime = orderTime;
		this.address = address;
		this.childorders = childorders;
		this.comments = comments;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "orderId", unique = true, nullable = false)
	public Integer getOrderId() {
		return this.orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "shipId")
	public Shipaddress getShipaddress() {
		return this.shipaddress;
	}

	public void setShipaddress(Shipaddress shipaddress) {
		this.shipaddress = shipaddress;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "state")
	public State getState() {
		return this.state;
	}

	public void setState(State state) {
		this.state = state;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "sumMoney", precision = 12, scale = 0)
	public Float getSumMoney() {
		return this.sumMoney;
	}

	public void setSumMoney(Float sumMoney) {
		this.sumMoney = sumMoney;
	}

	@Column(name = "orderTime", length = 45)
	public String getOrderTime() {
		return this.orderTime;
	}

	public void setOrderTime(String orderTime) {
		this.orderTime = orderTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
	public Set<Childorder> getChildorders() {
		return this.childorders;
	}

	public void setChildorders(Set<Childorder> childorders) {
		this.childorders = childorders;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
	public Set<Comment> getComments() {
		return this.comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}


	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
}